#include <cstdio>
#include <algorithm>

using namespace std;

struct Events
{
    int day, start, end;
    Events( int _day, int _start, int _end )
        : day( _day ), start( _start ), end( _end ) { }
    Events( ) { }
};

bool operator < ( const Events &a, const Events &b )
{
    if ( a.day < b.day )
        return true;
    if ( a.day > b.day )
        return false;
    return a.end < b.end;
}

int n, r;
Events e[ 50001 ];

void init( )
{
    int i;
    scanf("%d", &n);
    for ( i = 0; i < n; i++ )
        scanf("%d%d%d", &e[ i ].day, &e[ i ].start, &e[ i ].end);
    sort( e, e + n );
    r = 1;
}

void work( )
{
    int i, j, p = 0;
    for ( i = 0; i < n; i++ )
    {
        if ( e[ p ].day < e[ i ].day )
        {
            r++;
            p = i;
            continue;
        }
        if ( e[ p ].end <= e[ i ].start )
        {
            r++;
            p = i;
            continue;
        }
    }
}

void print( int p )
{
    printf("Scenario #%d:\n%d\n\n", p, r);
}

int main( )
{
    int i, t;
    scanf("%d", &t);
    for ( i = 1; i <= t; i++ )
    {
        init( );
        work( );
        print( i );
    }
    return 0;
}

